import React from 'react'
import Input from './input'
import './chatfooter.less'

class ChatFooter extends React.Component{

    // submit(){
    //
    //     console.log(this.state);
    //
    // },
    constructor(props){
        super(props)
        this.state={
            change:'',
        }
    }

    vauleChange(e){
        this.setState({
             change:e.target.value
        });
    }

    submit() {
        var chatnews = this.state.change
        console.log(chatnews)
        if(chatnews.length<3){
            alert('问题太短，请重新输入')
            this.setState({
                change:''
            })
            return
        }
        this.props.chatSubmit(chatnews)
        this.setState({
            change:''
        })
    }

    render(){
        return(
            <div className="chat-footer">
                <Input placeholder="请输入要查询的内容" ref='input'  name="name" value={this.state.change} vauleChange={(e)=>{this.vauleChange(e)}}></Input>
                <button onClick={()=>{this.submit()}}>请输入</button>
            </div>
        )
    }
}

export default ChatFooter